package common;

/**
 *
 * @author Slayer
 */
public class Item implements Cloneable {

    private ItemType type;
    private String name;

    public Item(ItemType type, String value) {
        this.type = type;
        this.name = value;
    }

    public ItemType getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    public Item setName(String newName) {
        return new Item(type, newName);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Item other = (Item) obj;
        if (this.type != other.type) {
            return false;
        }
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + (this.type != null ? this.type.hashCode() : 0);
        hash = 79 * hash + (this.name != null ? this.name.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return name;
    }

    @Override
    public Object clone() {
        return new Item(type, name);
    }
}
